package com.example.demo.controller;


import com.example.demo.config.UserInfo;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class Usercontroller {

/*    //1. 属性注入
    @Autowired
    private UserService userService;*/

    //2. 构造方法注入

    private UserService userService;
    private UserInfo userInfo;

    @Autowired
    public Usercontroller(UserService userService, UserInfo userInfo) {
        this.userService = userService;
        this.userInfo = userInfo;
    }


    public Usercontroller(UserService userService) {
        this.userService = userService;
    }

    public void doController() {
        userService.doservice();
        Integer id = userInfo.getId();
        System.out.println(id);
        System.out.println("do controller....");
    }
}
